<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box1{
            width: 500px;
            height: 500px;
            background-color: pink;
            margin: 0 auto;
            position: relative;
        }
        .box2{
            width: 200px;
            height: 150px;
            background-color: orange;
            /*定位方式实现水平盒子居中*/
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
        }

    </style>
</head>
<body>
<div class="box1">
    <div class="box2"></div>
</div>
</body>
</html>